<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1 th:text="${title}" style="display: inline-block"></h1>
    <a th:href="@{'/getData/accounting/'}+${batId}+'/'+${project.code}" type="button" class="btn btn-success"
       style="text-align:center;vertical-align:middle;font-size:30px;position:absolute;right:3%;display: inline-block;background-color: transparent;border: none;color: #5c5c5c;outline:none;">
        <i style="-moz-transform:scaleX(-1);-webkit-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1);filter:FlipH;"
           class="glyphicon glyphicon-share-alt"></i><span
            style="margin-left: 5px;font-size: 16px;position: absolute;top: 20%;">返回</span>
    </a>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <div class="row">
                        <div class="form-inline">
                            <div class="form-group">
                                <label class="control-label">
                                    项目编号：
                                </label>
                                <label class="control-label" th:text="${project.code}"></label>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    项目名称：
                                </label>
                                <label class="control-label" th:text="${project.name}"></label>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    需方：
                                </label>
                                <label class="control-label" th:text="${project.demander}"></label>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    安装地点：
                                </label>
                                <label class="control-label" th:text="${project.address}"></label>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    项目数量：
                                </label>
                                <label class="control-label" th:text="${project.num}"></label>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    设计类别：
                                </label>
                                <label class="control-label" th:text="${project.projectClassify == 1 ? '设计':'非设计'}"></label>
                            </div>
                        </div>
                    </div>
                <form id="queryForm" style="display: none">
                    <input type="hide" name="batId" th:value="${batId}" />
                    <input type="hide" name="dsId" th:value="${dataSource.id}" />
                    <input type="hide" name="part" th:value="${dataSource.part}" />
                    <input type="hide" name="major" th:value="${dataSource.major}" />
                    <input type="hide" name="dataSourceCode" th:value="${dataSource.dataCode}" />
                </form>
                </div>
                <div>
                    <button id="btn-clear-data" class="btn btn-danger">数据清空</button>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table-hours"></table>
                    <table id="bootstrap-table-material"></table>
                </div>
            </div>
        </div>
    </div>
</section>

<div th:include="include :: footer"></div>

<script th:inline="javascript">
    //表格对象
    let hoursTable,materialTable;


    //就绪函数
    $(function () {
        //加载系统类别表
        initTable();
        // /**
        //  * 模态框隐藏事件， 重置表单，重置验证
        //  */
        // js.modal.hideEvent("modal-edit", function () {
        //     js.validate.reset("halfAdjEditForm");
        //     js.reset("halfAdjEditForm");
        // });
        /**
         * 数据清空
         * */
        $("#btn-clear-data").on("click", function () {
            js.confirmPost({
                content: "清空数据将无法恢复，确认清空吗？",
                url: ctx + "getData/clearData",
                data: $("#queryForm").serialize(),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(hoursTable);
                        js.table.refresh(materialTable);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            });
        })

    });

    /**
     * 初始化表格
     */
    function initTable() {
        hoursTable = js.table.init({
            id:"bootstrap-table-hours",
            url: ctx + "getData/findHours",
            showColumns: true,
            showExport: true,
            queryForm: "queryForm",
            columns: [
                {
                    title: '序号', field: 'id', width: '60',
                    formatter: function (value, row, index, field) {
                        var pageSize = hoursTable.bootstrapTable('getOptions').pageSize;
                        var pageNumber = hoursTable.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }

                },
                {title: '部分', field: 'part'},
                {title: '专业', field: 'major'},
                {title: '热处理形式', field: 'laborName'},
                {title: '数量', field: 'laborNum'},
                {title: '单位', field: 'unit'},
                {title: '备注', field: 'remark'},
                {title: '提报人', field: 'postName'},
                {title: '提报部门', field: 'postDept'}
            ]
        });
    }


</script>
</body>
</html>